package com.xueyi.aixihu.pattern;

import com.xueyi.aixihu.constant.TwoLevelAuditConstant;

import java.util.Arrays;
import java.util.StringJoiner;

/**
 * 描述
 *
 * @author 刘梓江
 * @date 2023-12-12 11:15
 */
public abstract class FinanceReportStateStrategy {
    public abstract String gatStateInfo();
    public abstract int getStateLevel();
    public abstract String getColor();
    public boolean support(String state) {
        return Arrays.asList(gatStateInfo().split(",")).contains(state);
    }
}

//待提交状态
class FinanceReportWaitSubmitStateStrategy extends FinanceReportStateStrategy {

    private FinanceReportWaitSubmitStateStrategy() {
    }

    private final static FinanceReportWaitSubmitStateStrategy strategy = new FinanceReportWaitSubmitStateStrategy();

    public static FinanceReportWaitSubmitStateStrategy getInstance() {
        return strategy;
    }

    @Override
    public String gatStateInfo() {
        StringJoiner stringJoiner = new StringJoiner(",");
        stringJoiner.add(TwoLevelAuditConstant.DRAFT.toString());
        stringJoiner.add(TwoLevelAuditConstant.ONE_FAIL.toString());
        return stringJoiner.toString();
    }

    @Override
    public int getStateLevel() {
        return 1;
    }

    @Override
    public String getColor() {
        return "#ffafaf";
    }

}

//审核中状态
class FinanceReportUnderAuditStateStrategy extends FinanceReportStateStrategy {

    private FinanceReportUnderAuditStateStrategy() {
    }

    private final static FinanceReportUnderAuditStateStrategy strategy = new FinanceReportUnderAuditStateStrategy();

    public static FinanceReportUnderAuditStateStrategy getInstance() {
        return strategy;
    }

    @Override
    public String gatStateInfo() {
        StringJoiner stringJoiner = new StringJoiner(",");
        stringJoiner.add(TwoLevelAuditConstant.SUBMIT_AUDIT.toString());
        stringJoiner.add(TwoLevelAuditConstant.ONE_CONSENT.toString());
        stringJoiner.add(TwoLevelAuditConstant.TWO_FAIL.toString());
        return stringJoiner.toString();
    }

    @Override
    public int getStateLevel() {
        return 2;
    }

    @Override
    public String getColor() {
        return "#F9E2C0";
    }
}

//已通过状态
class FinanceReportAuditPassedStateStrategy extends FinanceReportStateStrategy {

    private FinanceReportAuditPassedStateStrategy() {
    }

    private final static FinanceReportAuditPassedStateStrategy strategy = new FinanceReportAuditPassedStateStrategy();

    public static FinanceReportAuditPassedStateStrategy getInstance() {
        return strategy;
    }

    @Override
    public String gatStateInfo() {
        StringJoiner stringJoiner = new StringJoiner(",");
        stringJoiner.add(TwoLevelAuditConstant.TWO_CONSENT.toString());
        return stringJoiner.toString();
    }

    @Override
    public int getStateLevel() {
        return 3;
    }

    @Override
    public String getColor() {
        return "#ACB9FD";
    }
}

//已公开状态
class FinanceReportPublicStateStrategy extends FinanceReportStateStrategy {

    private FinanceReportPublicStateStrategy() {
    }

    private final static FinanceReportPublicStateStrategy strategy = new FinanceReportPublicStateStrategy();

    public static FinanceReportPublicStateStrategy getInstance() {
        return strategy;
    }

    @Override
    public String gatStateInfo() {
        StringJoiner stringJoiner = new StringJoiner(",");
        stringJoiner.add(TwoLevelAuditConstant.PUBLIC.toString());
        return stringJoiner.toString();
    }

    @Override
    public int getStateLevel() {
        return 4;
    }

    @Override
    public String getColor() {
        return "#D9F7E5";
    }
}